<!--
 * @Date: 2021-11-30 15:42:07
 * @LastEditors: 春贰
 * @Desc: 
 * @LastEditTime: 2022-03-15 18:01:59
 * @FilePath: \web\src\component\authority\src\index.vue
-->
<template>
    <template v-if="hasAuthority">
        <slot></slot>
    </template>
</template>

<script>
import { computed, defineComponent } from "vue";
import { useStore } from 'vuex';

export default defineComponent({
	name: 'go2-authority',
	props: {
		value: {
			type: [String, Boolean],
			default: false
		},
	},
	setup(props) {
		const store = useStore();
		const hasAuthority = computed(() => {  
			if(props.value == false) return true;  
			let BoolhasAuthority = false
			store.getters.menu.forEach(v => {
				for (let index = 0; index < store.getters.menu.length; index++) {
					if (store.getters.menu[index].name==props.value) { 
							BoolhasAuthority = true
							break;
					}
				}
				
			});
			return BoolhasAuthority
		 
		});
		return {
			hasAuthority
		};
	},
});
</script>